package com.test.springboot.demo.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.test.springboot.demo.dao.HostDAO;
import com.test.springboot.demo.service.HostService;
import com.test.springboot.demo.pojo.HostIp;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class HostServiceImpl implements HostService {

    @Autowired
    private HostDAO hostDAO;

    @Override
    public PageInfo<HostIp> getHostList(String host, String ip, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        return new PageInfo(hostDAO.getHostList(host, ip));
    }

    @Override
    public HostIp getHostById(Integer id) {
        return hostDAO.getHostById(id);
    }

    @Override
    public void updateHost(HostIp hostIp) throws Exception{
        hostDAO.updateHost(hostIp);
       // throw new Exception("测试异常");
    }

    @Override
    public Integer getHostId(String host, Integer port) {
        return hostDAO.getHostId(host, port);
    }
}
